//
// Created by LONG on 2020/10/19.
//

#ifndef O5G_SRC_O5GUE_L1_INCLUDE_L1DEF_H_
#define O5G_SRC_O5GUE_L1_INCLUDE_L1DEF_H_

#include "../../../../lib/csp/include/cspApi.h"
#include "../../include/ueApi.h"
#include "../../lcore/include/commDef.h"

#define UE_L1_TTI_BUFF_NUM  8

typedef enum
{
    UE_L1_APP_STATE_IDLE,
    UE_L1_APP_STATE_CONFIG,
    UE_L1_APP_STATE_SYNC,
    UE_L1_APP_STATE_RUNNING,
    UE_L1_APP_STATE_BUTT
} E_UeL1AppState;

typedef struct UeL1UeInst
{
    uint32_t inUse;
    uint32_t ueId;

    uint32_t ueIdx;

    E_UeL1AppState appState;

    uint32_t sendTtiIntCount;
    uint32_t recvTtiReqCount;

    S_OsSelect ttiIntSelector;

    uint16_t sfn;
    uint16_t slot;
    uint16_t slotNum;

    S_VarRingBuffer *pL2L1CpMsgQue;
    S_VarRingBuffer *pL1L2CpMsgQue;
    S_VarRingBuffer *pL2L1UpMsgQue;
    S_VarRingBuffer *pL1L2UpMsgQue;

    S_VarRingBuffer *pUlTtiBuff[UE_L1_TTI_BUFF_NUM];
    S_VarRingBuffer *pDlTtiBuff[UE_L1_TTI_BUFF_NUM];

    S_VarRingBuffer *pRanUeQue;
    S_VarRingBuffer *pUeRanQue;

} S_UeL1UeInst;

typedef struct UeL1Context
{
    pthread_t tid;

    uint32_t ueInstNum;
    S_UeL1UeInst ueInst[UE_UE_INST_NUM_MAX];
} S_UeL1Context;

extern S_UeL1Context *gpUeL1Context;

#endif //O5G_SRC_O5GUE_L1_INCLUDE_L1DEF_H_
